<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>趋势列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!--绘制用户列表卡片-->
    <el-card>
      <div id="main" style="width: 100%;height:400px;"></div>
    </el-card>
  </div>
</template>

<script>
// 导入Echarts 需要的库
import echarts from "echarts";
import _ from 'lodash'
export default {
  data() {
    return {
      option : {
          title: {
              text: '提交趋势图',
              x:'center'
          },
          tooltip: {
              trigger: 'axis',
              axisPointer: {
                  type: 'cross',
                  label: {
                      backgroundColor: '#6a7985'
                  }
              }
          },
          xAxis: {
              type: 'category',
              boundaryGap: false,
              data: []
          },
          yAxis: {
              type: 'value'
          },
          series: [{
              // data: [820, 932, 901, 934, 1290, 1330, 1320],
              data: [],
              type: 'line',
              areaStyle: {}
          }]
        }
    };
  },

  methods: {},

  created() {},

  async mounted() {
   // 3.基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'))
     const { data: res } = await this.$http.get('statistics')

    if (res.meta.code !== 200) return this.$message.error('获取折线图数据失败!')
    
    this.option.xAxis.data = res.data.dateData;
    this.option.series[0].data = res.data.submitCountData;
    // 数据合并
    // const result = _.merge(res.data, this.options)
    // 5.展示数据
    myChart.setOption(this.option)
  }
};
</script>

<style lang="less" scope></style>
